package com.pactera.asmp.server.restfullapi;

import com.pactera.asmp.server.entity.ResponseResult;
import com.pactera.asmp.server.service.ScreenDataService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/screen")
public class RestfullScreenApi {

    private static final Logger logger = LoggerFactory.getLogger(RestfullScreenApi.class);

    @Autowired
    private ScreenDataService screenDataService;

    @GetMapping("/issueprocessname")
    public ResponseResult getIssueProcessNameByProject(@RequestParam("projectId") Integer projectId) {
        logger.info("GET /api/v1/screen/issueprocessname  getIssueProcessNameByProject:{}",projectId);
        return ResponseResult.defaultSuccess(screenDataService.getIssueProcessNameByProject(projectId));
    }

    @GetMapping("/imgdevices")
    public ResponseResult getScreenTaskingDeviceListByProjectId(@RequestParam("projectId") Integer projectId) {
        logger.info("GET /api/v1/screen/devices  getScreenTaskingDeviceListByProjectId:{}",projectId);
        return ResponseResult.defaultSuccess(screenDataService.getScreenTaskingDeviceListByProjectId(projectId));
    }

    @GetMapping("/devices")
    public ResponseResult getScreenDeviceListByProjectId(@RequestParam("projectId") Integer projectId) {
        logger.info("GET /api/v1/screen/devices  getScreenDeviceListByProjectId:{}",projectId);
        return ResponseResult.defaultSuccess(screenDataService.getScreenDeviceListByProjectId(projectId));
    }

    @GetMapping("/masters")
    public ResponseResult getScreenMasterListByProjectId(@RequestParam("projectId") Integer projectId) {
        logger.info("GET /api/v1/screen/masters  getScreenMasterListByProjectId:{}",projectId);
        return ResponseResult.defaultSuccess(screenDataService.getScreenMasterListByProjectId(projectId));
    }

}
